package com.lujianfei.common.widget

import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import android.widget.TextView
import com.lujianfei.common.R

class CustomToolbar @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr) {

    private var txt_title:TextView ?= null

    init {
        val obtainStyledAttributes =
            context.obtainStyledAttributes(attrs, R.styleable.CustomToolbar)
        LayoutInflater.from(context).inflate(R.layout.widget_custom_toolbar, this ,true)
        initView()
        initData(obtainStyledAttributes)
        obtainStyledAttributes.recycle()
    }

    private fun initData(obtainStyledAttributes: TypedArray) {
        txt_title?.text = obtainStyledAttributes.getString(R.styleable.CustomToolbar_title)
    }

    private fun initView() {
        txt_title = findViewById(R.id.txt_title)
    }


}